<!doctype html>
<html>

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  <meta name="misapplication-tap-highlight" content="no" />
  <meta name="HandheldFriendly" content="true" />
  <meta name="MobileOptimized" content="320" />
  <title>QmSdk-Auth</title>
  <style>
    .button {
      text-align: center;
      line-height: 3em;
      border: 1px solid #ccc;
      border-radius: 8px;
      margin-bottom: 1em;
    }

    .button:last-child {
      margin-bottom: 0;
    }

    .button:active {
      background-color: aliceblue;
    }

  </style>
</head>

<body>
  <div class="button" onclick="handleClick('camera')">
    相机权限
  </div>

  <div class="button" onclick="handleClick('microphone')">
    麦克风权限
  </div>

  <div class="button" onclick="handleClick('calendars')">
    日历权限
  </div>

  <div class="button" onclick="handleClick('bluetooth')">
    蓝牙权限
  </div>

  <div class="button" onclick="handleClick('contacts')">
    通讯录权限
  </div>

  <div class="button" onclick="handleClick('location')">
    定位权限
  </div>

  <script src="../qmsdk.js"></script>
  <script>
    function handleClick(type) {
      if (type == "camera") {
        window.qmSdk.getCameraAuth({
          success: () => {
            // alert("success");
            console.log("执行成功");
          },
          fail: (err) => {
            alert("fail")
          }
        })
      }

      if (type == "microphone") {
        window.qmSdk.getMicrophoneAuth({
          success: () => {
            // alert("success")
          },
          fail: (err) => {
            alert("fail")
          }
        })
      }

      if (type == "calendars") {
        window.qmSdk.getCalendarsAuth({
          success: () => {
            // alert("success")
          },
          fail: (err) => {
            alert("fail")
          }
        })
      }

      if (type == "bluetooth") {
        window.qmSdk.getBluetoothAuth({
          success: () => {
            // alert("success")
          },
          fail: (err) => {
            alert("fail")
          }
        })
      }

      if (type == "contacts") {
        window.qmSdk.getAddressBook({
          success: () => {
            // alert("success")
          },
          fail: (err) => {
            alert("fail")
          }
        })
      }

      if (type == "location") {
        window.qmSdk.getLocationAuth({
          success: () => {
            // alert("success")
          },
          fail: (err) => {
            alert("fail")
          }
        })
      }
    }

  </script>
</body>

</html>
